{extend name="base" /}
{block name="body"}
<div class="layui-body">
    <!--tab标签-->
    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class=""><a href="{:url('admin/goods/index')}">商品列表</a></li>
            <li class="layui-this">修改商品</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <form class="layui-form form-container" action="{:url('admin/goods/edit')}" method="post">
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品名称</label>
                        <div class="layui-input-block">
                            <input type="text" name="name" value="{$goods_list.name}" required  lay-verify="required" placeholder="请输入商品名称" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 300px;">
                        <label class="layui-form-label">原价</label>
                        <div class="layui-input-block">
                            <input type="text" name="orgin_price" class="layui-input" value="{$goods_list.orgin_price}" placeholder="（必填）价格 示例:5.20">
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 300px;">
                        <label class="layui-form-label">现价</label>
                        <div class="layui-input-block">
                            <input type="text" name="current_price" class="layui-input" value="{$goods_list.current_price}" placeholder="（必填）价格 示例:5.20">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">描述</label>
                        <div class="layui-input-block">
                            <textarea name="description" placeholder="（选填）请输入商品描述" class="layui-textarea">{$goods_list.description}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 300px;">
                        <label class="layui-form-label" >规格</label>
                        <div class="layui-input-block">
                            <input type="text" name="spec" class="layui-input" value="{$goods_list.spec}" placeholder="（必填)">
                        </div>
                    </div>
                    <div class="layui-form-item" style="width: 300px;">
                        <label class="layui-form-label">库存</label>
                        <div class="layui-input-block">
                            <input type="text" name="stock" placeholder="（必填)" value="{$goods_list.stock}" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">商品详情页</label>
                        <div class="layui-input-block">
                            <textarea name="content" placeholder=""  class="layui-textarea" id="content">{$goods_list.content}</textarea>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">缩略图</label>
                        <div class="layui-input-block">
                            <input type="hidden" name="thumb" value="{$goods_list.thumb}" class="layui-input layui-input-inline" id="thumb">
                            <button type="button" class="layui-btn" id="one-image-upload">
                                <i class="layui-icon">&#xe67c;</i>上传图片
                            </button>
                        </div>
                        <div class="layui-input-block" {if condition="$goods_list.thumb eq ''"}style="display:none"{/if} id="layui-img">
                            <img id="show-img" src="{$goods_list.thumb}" width="80px" height="80px"/>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <label class="layui-form-label">图集</label>
                        <div class="layui-input-block">
                            <input type="file" id="file" style="display: none;" name="file">
                            <button type="button" class="layui-btn" id="photos" onclick="$('#file').click()">上传图集</button>
                            <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                预览图：
                                <div class="layui-upload-list" id="demo2">
                                    {if condition="$goods_list.photos neq ''"}
                                    {foreach name="$goods_list.photos" item="vo" key="k"}
                                    <div class="layui-inline">
                                        <img src="{$vo}" alt="" class="layui-upload-img" style="width: 60px;height: 60px;">
                                        <input type="hidden" name="photos[]" value="{$vo}">
                                        <div>
                                            <button onclick="$(this).parent('div').parent('div').remove();">删除</button>
                                        </div>
                                    </div>
                                    {/foreach}
                                    {/if}
                                </div>
                            </blockquote>
                        </div>
                    </div>
                    <!--<div class="layui-bf-form-item">-->
                    <!--<label class="layui-bf-form-label">图集</label>-->
                    <!--<div class="layui-bf-input-block">-->
                    <!--<button type="button" id="upload-photo-btn" class="layui-bf-btn">上传图集</button>-->
                    <!--<div id="photo-container"></div>-->
                    <!--</div>-->
                    <!--</div>-->
                    <div class="layui-form-item">
                        <label class="layui-form-label">标签选择</label>
                        {foreach name="label_list" item="val"}
                        <input type="radio" name="label_id" title="{$val.name}" value="{$val.id}" {if condition="$goods_list['label_id']==$val.id"}checked{/if}/>
                        {/foreach}
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <input type="hidden" name="id" value="{$goods_list.id}">
                            <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="js"}
<script src="__JS__/kindeditor/kindeditor.config.js"></script>
<script src="__JS__/kindeditor/kindeditor-all-min.js"></script>
{/block}
{block name="script"}
<script>
    $(document).ready(function () {
        var _kindEditor;
        KindEditor.ready(function(K) {
            _kindEditor = K.create('#content', KindEditorOptions);
            _kindEditor = K.create('#pay-content', KindEditorOptions);
            K('#upload-photo-btn').click(function () {
                var photo_list_item = '';
                _kindEditor.loadPlugin('multiimage', function() {
                    _kindEditor.plugin.multiImageDialog({
                        showRemote : false,
                        imageUrl : K('#photo').val(),
                        clickFn : function(data) {
                            $.each(data, function (index, item) {
                                photo_list_item += '<div class="photo-list"><input type="text" name="photo[]" value="' + item.url + '" class="layui-input layui-input-inline">';
                                photo_list_item += '<button type="button" class="layui-btn layui-btn-danger remove-photo-btn">移除</button></div>'
                            });
                            $('#photo-container').append(photo_list_item);
                            _kindEditor.hideDialog();
                        }
                    });
                });
            });
        });
    });
</script>
{/block}